package com.atguigu.spring5.service;

import com.atguigu.spring5.dao.BookDao;
import com.atguigu.spring5.entity.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {
    //注入dao
    @Autowired
    private BookDao bookDao;
    //添加方法
    public void addBook(Book book){
        bookDao.add(book);
    }
    //删除方法
    public void deleteBook(String id){
        bookDao.delete(id);
    }
    //修改方法
    public void updateBook(Book book){
        bookDao.update(book);
    }
    //查询表总记录数
    public int findCount(){
        return bookDao.selectCount();
    }
    //查询结果，返回一个对象
    public Book findBook(String id){
        return bookDao.findBookInfo(id);
    }
    //查询结果，返回一个集合
    public List<Book> findBookList(){
        return bookDao.findListInfo();
    }
    //批量操作
    public void batchAdd(List<Object[]> batchArgs){
        bookDao.batchAddBook(batchArgs);
    }
}
